#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool fun(TreeNode* Left, TreeNode* Right) {
        if (Left == nullptr && Right == nullptr)
            return true;
        if (Left == nullptr && Right != nullptr)
            return false;
        if (Left != nullptr && Right == nullptr)
            return false;
        if (Left->val != Right->val)
            return false;

        return fun(Left->left, Right->right) && fun(Left->right, Right->left);

    }

    bool isSymmetric(TreeNode* root) {
        if (root == nullptr)
            return true;
        return fun(root->left, root->right);
    }
};